package com.leetcode.LC;

public class LC557 {
    public String reverseWords(String s) {

        if (s.length()==0){
            return "";
        }
        String[] strings = s.split(" ");
        StringBuilder builder = new StringBuilder();
        for (String string : strings) {
            builder.append(new StringBuilder(string).reverse().toString() + " ");
        }
        return builder.toString().substring(0, builder.length() - 1);
    }

    public static void main(String[] args) {
        System.out.println(new LC557().reverseWords("Let's take LeetCode contest"));
        System.out.println(new LC557().reverseWords("L"));
    }
}
